Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: significantly reduce form-state response size by up to 2x #9388

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

jacobsfletch
Copy link
Member

@jacobsfletch jacobsfletch commented Nov 20, 2024

This significantly optimizes the form-state response, reducing its size by up to more than 2x. This has rolling effects on initial page size as well, where the initial state for the entire form is sent through the request. To achieve this, we do the following:

  • Remove $undefined strings that are potentially attached to properties like value, initialValue, fieldSchema, etc.
  • Remove unnecessary properties like empty errorPaths arrays and empty customComponents objects, which only need to exist if used
  • Remove unnecessary properties like valid, passesCondition, etc. which only need to be returned if explicitly false
  • Remove unused properties like isSidebar, which simply don't need to exist at all, as they can be easily calculated during render

For backward compatibility, some of these changes are behind a temporary experimental.optimized flag.

Results

The following results were gathered by booting up each test suite listed below using the existing seed data, navigating to a document in the relevant collection, then typing a single letter into the noted field in order to invoke new form-state. The result is then saved to the file system for comparison.

Test Suite Collection Field Before After
field-perf blocks-collection layout.0.field1 177 kB 98 kB
fields array-fields items.0.text 8 kB 4 kB
fields block-fields blocks.0.richText 28 kB 22 kB

@jacobsfletch jacobsfletch changed the title perf: optimizes form state response by removing undefined and unnecessary properties perf: significantly reduce form state response size Nov 20, 2024
@jacobsfletch jacobsfletch changed the title perf: significantly reduce form state response size perf: significantly reduce form-state response size by up to 2x Nov 21, 2024
@jacobsfletch jacobsfletch marked this pull request as ready for review November 21, 2024 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants